package Chapter2.Comparing.c9.Communication;

public class ContainerTest {
    private static int product = 0;

    public int getProduct() {
        return product;
    }

    public void setProduct(int product) {
        this.product = product;
    }

    public static void main(String[] args) {

        /*Container<Integer> container = new Container<>();

        container.save(1);
        container.save(2);
        container.save(3);
        container.save(4);
        container.save(5);
        int len = container.count();
        for (int i=0;i<len;i++) {
            System.out.println(container.fetch());
        }*/
        /*Produce produce = new Produce();
        Consume consume = new Consume();
        Thread t1 = new Thread(produce,"produce:");
        Thread t2 = new Thread(consume,"consume:");
        t1.start();t2.start();
    }
}*/

/*class Produce implements Runnable {
    Container<Integer> container = new Container<>();
    ContainerTest ct = new ContainerTest();
    int p =0;
    @Override
    public void run() {
        while (true){
            ct.setProduct(p++);
            container.save(ct.getProduct());
            System.out.println(Thread.currentThread().getName()+ct.getProduct());


        }

        *//*product++;
        container.save(product);
        System.out.println(Thread.currentThread().getName()+":"+product);*//*
        //product++;
        *//*try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }*//*
         *//*container.fetch();
        product--;
        System.out.println(Thread.currentThread().getName()+":"+product);*//*
    }
}

*//*class Consume implements Runnable {
        Container<Integer> container = new Container<>();
        ContainerTest ct = new ContainerTest();
        int p =0;
        @Override
        public void run() {
            while (true){
                container.fetch();
                ct.setProduct(p--);
                System.out.println(Thread.currentThread().getName()+p);
            }
        }
}*/
    }}